import commonData from "./data";

const CommonReducer = (state = commonData, action) => {
  switch (action.type) {
    case "SET_USERINFO":
      return Object.assign({}, state, {
        userInfo: action.data,
      });
    case "SET_ENV":
      return Object.assign({}, state, {
        env: action.data,
      });
    case "SET_MAINSERVER":
      return Object.assign({}, state, {
        mainServer: action.data,
      });
    case "SET_RESOURCEADDR":
      return Object.assign({}, state, {
        ResourceServerAddr: action.data,
      });
    case "SET_PUBLICINFOADDR":
      return Object.assign({}, state, {
        PublicInfoServerAddr: action.data,
      });
    case "SET_BASEURL":
      return Object.assign({}, state, {
        baseUrl: action.data,
      });
    case "SET_IDENTITYCODE":
      return Object.assign({}, state, {
        lg_ic: action.data,
      });
    case "SET_TOKEN":
      return Object.assign({}, state, {
        token: action.data,
      });
    case "SET_TERMINFO":
      return Object.assign({}, state, {
        termInfo: action.data,
      });
    case "SET_MODULEINFO":
      return Object.assign({}, state, {
        moduleInfo: action.data,
      });
    case "SET_NOTICEADDR":
      return Object.assign({}, state, {
        noticeAddr: action.data,
      });
    case "SET_OFFICEADDR":
      return Object.assign({}, state, {
        officeAddr: action.data,
      });
    case "SHOW_TOAST":
      return Object.assign({}, state, {
        showMessage: action.data,
      });
    case "SET_ISEDU":
      return Object.assign({}, state, {
        isEdu: action.data,
      });
    case "SET_CHATURL":
      return Object.assign({}, state, {
        chatUrl: action.data,
      });

    case "SET_CURRENTSYSTEM":
      return Object.assign({}, state, {
        currentSystem: action.data,
      });
    default:
      return state;
  }
};

/**
 * 如果有多个reducer函数，则可以使用combineReducers进行合并
 *export default combineReducers({
     reducer1,
     reducer2
 })
 */
export default CommonReducer;
